#!/usr/bin/env python
#coding=utf-8
import threading
from threading import Timer

semaphore = threading.Semaphore(2)

def func():
	if semaphore.acquire():
		print threading.currentThread().getName() + 'get semaphore'
		semaphore.release()
		print threading.currentThread().getName() + 'release semaphore'

for i in xrange(5):
	t1 = Timer(30.0, func)
	t1 = threading.Thread(target=func)
	t1.start()